﻿using Power.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Power.View
{
    /// <summary>
    /// Demo.xaml 的交互逻辑
    /// </summary>
    public partial class Demo : Window
    {
        public Demo()
        {
            InitializeComponent();
            DataList = new List<DemoDataModel>();
            for (int i = 0; i < 20; i++)
            {
                DataList.Add(new DemoDataModel()
                {
                    Index = i,
                    Name = i.ToString(),
                    Type = 0,

                });
            }
            //(grid as DataGrid).ItemsSource = DataList;
        }

        private void Pagination_PageUpdated(object sender, HandyControl.Data.FunctionEventArgs<int> e)
        {
            DataList = DataList.Skip((e.Info - 1) * 10).Take(10).ToList();
        }

        public class DemoDataModel
        {
            public int Index { get; set; }
            public string Name { get; set; }
            public bool IsSelected { get; set; }
            public int Type { get; set; }
        }
        
        /// <summary>
        /// 所有数据
        /// </summary>
        private List<DemoDataModel> DataList;


        /// <summary>
        ///     页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        private void grid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGrid dg = sender as DataGrid;
            var cell = dg.CurrentCell;//获取当前选中的列
            if (cell != null)
            {
                //this.SectionDataGrid1.Columns[cell.DisplayIndex].Visibility = Visibility.Hidden;
            }
            SiteModel a = (SiteModel)dg.SelectedItem;// 获取选中的行
            //if (cell.DisplayIndex != 0)// 第一个复选框不能隐藏
            //{
            //    cell.Visibility = Visibility.Hidden;
            //}
        }
    }
}
